﻿using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Activation;

using ibba.src.norisk.BusinessLogic;
using ibba.src.norisk.Contracts;


/*****************************************************************************************************************          
 Copyright © 2010 - Banco Itaú BBA S.A          
          
 Natureza  : 
            
 Histórico de Alterações:      
12/08/2010 - AAALVES	- Criacao OS393398

 *****************************************************************************************************************/

namespace ibba.src.norisk.ServiceImplementation
{

    [AspNetCompatibilityRequirements(RequirementsMode = System.ServiceModel.Activation.AspNetCompatibilityRequirementsMode.Allowed)]
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession,
                     ConcurrencyMode = ConcurrencyMode.Multiple)]

    class Natureza : INatureza
    {

        private NaturezaBL _naturezaBL;

        public Natureza()
        {

            try
            {
                _naturezaBL = new NaturezaBL();
            }
            catch (Exception ex)
            {
                global.ErrorHandler.LogAndThrowFaultException(ex);
            }

        }

        public List<ibba.src.norisk.Contracts.Natureza> ObterNatureza(int pCodBem, int pCodInstrumento)
        {
            List<ibba.src.norisk.Contracts.Natureza> retorno = null;

            try
            {

                retorno = TranslateNatureza.Translate(_naturezaBL.ObterNatureza(pCodBem, pCodInstrumento));
            }
            catch (Exception ex)
            {
                global.ErrorHandler.LogAndThrowFaultException(ex);
            }

            return (retorno);
        }

        public int AtualizarNatureza(List<Contracts.Natureza> pNatureza, string pCodUsuario)
        {
            int retorno = 0;

            try
            {

                retorno = _naturezaBL.AtualizarNatureza(TranslateNatureza.Translate(pNatureza), pCodUsuario);
            }
            catch (Exception ex)
            {
                global.ErrorHandler.LogAndThrowFaultException(ex);
            }

            return (retorno);
        }

    }
}
